package com.power.ding.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.ding.model.Di_userdept;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 用户部门关系 持久层(hibernate)
 */

public interface Di_userdeptDao extends JpaRepository<Di_userdept, Serializable>, JpaSpecificationExecutor<Di_userdept>, Repository<Di_userdept, Serializable>, Di_userdeptDaoCustom<Di_userdept, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Di_userdept s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);

   @Modifying
   @Transactional
   @Query("delete  from Di_userdept s where  s.userId = :userid ")
   void removeByUserId(@Param("userid") String userid);


   @Transactional
   @Query(value = "select count(*),orgid from di_userdept where rowState >=0 group by orgid", nativeQuery = true)
   List<Map<String, Object>> countByOrgId();
}
